home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: a1s@ix.netcom.com (Andrew Snyder)
- Newsgroups: comp.lang.c
- Subject: Re: Who's dumb: me or my compiler ?
- Date: Mon, 12 Feb 1996 22:07:26 GMT
- Organization: Netcom
- Message-ID: <4fo3ci$nt1@cloner2.ix.netcom.com>
- References: <4fnmhd$c1o@micky.ibh-dd.de>
- NNTP-Posting-Host: ix-har5-06.ix.netcom.com
- X-NETCOM-Date: Mon Feb 12 11:11:14 AM PST 1996
- X-Newsreader: Forte Free Agent 1.0.82
-
- beck@duck.ibh-dd.de (Andre Beck) wrote:
-
- >Hi,
-
- >I could have had a really bad day searching for this bug, but for
- >some lucky circumstances, I trapped it instantly. However I don't
- >know whether I wrote bad code or whether a number of compilers do
- >it wrong in the same way - the latter doesn't sound that probable ;)
-
- >My problem turns around the expression
-
- > x = (*ptr++ << 8) | *ptr++;
-
- --snip
-
- Its you who is dumb. Anybody who expects an expression with the form
- A = B++ + B++ to behave is looking for trouble. The compiler doesn't
- have to guarentee you anything about when both postfixs are processed.
-
- try
- x = *ptr++ <<8;
- x |= *ptr++;
- Andrew Snyder
- a1s@ix.netcom.com
- char disclaimer[] = {'\0'}; /* I'm on cash net */
-
-